import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.util.*;

import com.sleepycat.bind.EntryBinding;
import com.sleepycat.bind.serial.SerialBinding;
import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Transaction;

public class ObjPutTest {
	
	private static File[] files;
	private static BerkeleyDBWrapper wrapper;
	private static DateSeries DateSeries;
	
	public ObjPutTest() throws DatabaseException, FileNotFoundException{
		wrapper = new BerkeleyDBWrapper("./DBTEST"); 
		DateSeries = new DateSeries();
	}

	public static void main(String args[]){
		try {
			ObjPutTest o = new ObjPutTest();
		} catch (DatabaseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		ArrayList<String> tester = new ArrayList<String>();
		tester.add("hello");
		tester.add("world");
		tester.add("please");
	//	wrapper.putDBSimpleVal("hello","world");
		//System.out.println(wrapper.getDBStringVal("hello"));
		wrapper.putDBObjVal("test",tester);
 	//	byte[] s = wrapper.getDBObjVal("test");
 	//	ArrayList<Byte> b = saveBytesArraytoBytesArrayList(s);
 		ArrayList<String> back = wrapper.getDBArrayListVal("test");
 		//String temp = "";
 		/*for (int i=0; i<s.length ;i++){
 			Character c = new Character((char) s[i]);
 			char m = c.charValue();
 			if(m!='['&&m!=']'&&m!=','){
 				if(temp==""){
 					temp = c.toString();
 				}else{
 	 				temp = temp.concat(c.toString());
 				}
 			}else if (c == ',' || c == ']'){
 				back.add(temp);
 				temp = "";
 			}
 		}*/
 		System.out.println(back.get(0)+" "+back.get(1)+" "+back.get(2));
		//List<Object> out = java.util.Arrays.asList(wrapper.getDBObjVal("test"));
//		System.out.println(out.get(0));
 		wrapper.putDBSimpleVal("the number 4", "4");
 		wrapper.putDBSimpleVal("the number 5", "5");
 		System.out.println(wrapper.getDBDoubleVal("the number 4")+wrapper.getDBDoubleVal("the numner 5"));
 		System.out.println(wrapper.getDBDoubleVal("the number 4")+wrapper.getDBDoubleVal("the number 5"));
 		List<String> s = DateSeries.getDateSeries("3/6/2010","4/25/2010");
 		for(int i =0;i<s.size();i++){
 			System.out.println(s.get(i));
 		}
	}
}
